package com.qn.controller;

import cn.hutool.jwt.JWTUtil;
import com.qn.vo.LoginReqVO;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/auth")
public class LoginController {

    private static final byte[] SECRET = "123456".getBytes();

    // 模拟用户登录接口
    @PostMapping("/login")
    public Map<String, String> login(@RequestBody LoginReqVO reqVO) {
        Map<String, Object> payload = new HashMap<>();
        payload.put("username", reqVO.getUsername());
        String token = JWTUtil.createToken(payload, SECRET);
        return Map.of("token", token);
    }
}
